package demo2;

import demo1.Test;

public enum TestEnum {
    RED(1,"红色"), GREEN(2,"绿色"), BLACK(3,"黑色");

    private int ordinal;
    private String color;
    private TestEnum(int ordinal,String color){
        this.ordinal = ordinal;
        this.color = color;
    }

    public static void main(String[] args) {
        TestEnum[] testEnums = TestEnum.values();
        for (int i = 0; i < testEnums.length; i++) {
            System.out.println(testEnums[i].ordinal());
        }
        System.out.println("===");
        TestEnum v = TestEnum.valueOf("GREEN");
        System.out.println(v);
        System.out.println("===");
        System.out.println(RED.compareTo(BLACK));
    }

    public static void main1(String[] args) {
        TestEnum color = RED;
        switch (color) {
            case GREEN:
                System.out.println("GREEN");
                break;
            case RED:
                System.out.println("RED");
                break;
            case BLACK:
                System.out.println("BLACK");
                break;
            default:
                System.out.println("error");
                break;
        }
    }
}
